<template>
  <div class="container">
    <x-header @on-click-back="toback" :left-options="{preventGoBack:true}" title="买房登记"></x-header>
    <div class="form-wrap">
      <div class="input-item flex-row flex-y-center">
        <label>您的姓名：</label><input v-model="formData.userName" class="flex-grow-1" type="text">
      </div>
      <div class="input-item flex-row flex-y-center">
        <label><span class="red">*</span>您的电话：</label><input v-model="formData.phoneNumber" class="flex-grow-1"
                                                             type="text">
      </div>
      <div class="input-item flex-row flex-y-center">
        <label>大概总价：</label><input v-model="formData.totalPrice" class="commen" type="text"><span>万元</span>
      </div>
      <div class="input-item flex-row flex-y-center">
        <label>大概面积：</label><input v-model="formData.area" class="commen" type="text"><span>平米</span>
      </div>
      <div class="textArea flex-row flex-y-center">
        <label>备注说明：</label><textarea v-model="formData.description" class="flex-grow-1"></textarea>
      </div>
    </div>
    <button @click="submitClick" class="submitBtn">提交</button>
  </div>
</template>

<script>
  import {XHeader} from 'vux'
  import {URI_BUYHOUSEREGISTER} from 'src/const/shareUri'

  export default {
    name: "BuyHouseRegester",
    components: {XHeader},
    data() {
      return {
        formData: {
          userName: '',
          phoneNumber: '',
          totalPrice: '',
          area: '',
          description: ''
        }
      }
    },
    methods: {
      toback() {
        let url = cdnBase + '/index.html';
        window.location.href = url
      },
      submitClick() {
        var phoneRule = /^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[7]))\d{8}$/;
        if (!phoneRule.test(this.formData.phoneNumber)) {
          this.$vux.toast.text('手机号不正确！');
          return false;
        }
        this.$ajax.post(URI_BUYHOUSEREGISTER, {
          formData: this.formData
        }, res => {
          this.$vux.alert.show({
            content: '在线委托成功，经纪人稍后和您联系！',
            onShow() {

            },
            onHide() {
              let url = cdnBase + '/index.html';
              window.location.href = url;
            }
          })
        });
      }
    }
  }
</script>

<style lang="less" scoped>

  @import "./commen";

</style>